package gold.digger;

import gold.utils.InputUtil;

/**
 * Created by fanzhenyu02 on 2020/6/27.
 * common problem solver template.
 */
public class LC275 {
    public long startExecuteTime = System.currentTimeMillis();


    class Solution {
        public int hIndex(int[] citations) {
            if (null == citations || citations.length <= 0 || citations[citations.length - 1] == 0) return 0;

            int hIndex = -1;
            for (int i = citations.length - 1; i >= 0; i--) {
                if (citations[i] >= citations.length - i) hIndex = citations.length - i;
                else break;
            }

            return hIndex;
        }
    }

    public void run() {
        Solution solution = new Solution();
        int[] arr = InputUtil.toIntegerArray("[0,1]");
        System.out.println(solution.hIndex(arr));
    }

    public static void main(String[] args) throws Exception {
        LC275 an = new LC275();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
